package com.xin.jdbc;

import java.sql.*;

public class jdbcdemo_01 {
    public static void main(String[] args) {
        Connection conn=null;
        Statement sta=null;
        ResultSet re=null;
        try {
            //注册驱动
            DriverManager.registerDriver(new com.mysql.jdbc.Driver());
            //获取连接
            conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/student_manage","root","856736");
            //获取数据库操作对象
            sta=conn.createStatement();
            //执行sql语句
            sta.executeUpdate("delete from stu_information where  stu_id=2 ");
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            //6、释放资源
            if (re!=null){
                try {
                    re.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }if (sta!=null){
                try {
                    sta.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }if (conn!=null){
                try {
                    conn.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
